package org.shark.jdbcTemplateTool.dao.config;

import org.shark.jdbcTemplateTool.binding.DaoProxyFactory;
import org.springframework.beans.factory.FactoryBean;

/**
 * Created by xiaojun on 16/8/24.
 */
public class DaoFactoryBean<T> implements FactoryBean<T> {

    private Class<T> daoInterface;
    
    public DaoFactoryBean(Class<T> daoInterface) {
    	this.daoInterface = daoInterface;
    }
    
    public DaoFactoryBean() {}

    @Override
    public T getObject() throws Exception {
        return DaoProxyFactory.newInstance(daoInterface);
    }

    @Override
    public Class<?> getObjectType() {
        return daoInterface;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

	public Class<T> getDaoInterface() {
		return daoInterface;
	}

	public void setDaoInterface(Class<T> daoInterface) {
		this.daoInterface = daoInterface;
	}
    
}
